package twitter.TwitterLibrary;
/*********************************************
 * this class is designed for help building http request
 * @author fang
 *
 */
public class HTTPHelper {
	/****************************************
	 * this method is used to construct http header
	 * @param return_code
	 * @return
	 */
	public String construct_http_header(int return_code) {
		String s = "HTTP/1.1 ";

		switch (return_code) {
		case 200:
			s = s + "200 OK";
			break;
		case 204:

			s = s + " 204 No Content";
			break;
		case 400:
			s = s + "400 Bad Request";
			break;
		case 404:
			s = s + "404 Not Found";
			break;
		case 500:
			s = s + "500 Internal Server Error";
			break;
		case 501:
			s = s + "501 Not Implemented";
			break;
		case 505:
			s = s + "505 HTTP version not supported";
			break;
		}

		s = s + "\r\n"; // other header fields,
		s = s + "Connection: close\r\n"; // we can't handle persistent

		// connections
		s = s + "Server: localhost\r\n"; // server name
		s = s
				+ "Content-type: text/xml,text/plain, text/html,charset=UTF-8\r\n";

		s = s + "\r\n";
		return s;
	}
/**************************************************************
 * this method is used to construct http message
 * @param number
 * @return
 */
	public String httpMessage(int number) {
		switch (number) {
		case 200:
			return "<html><title>test</title><body> 200 OK - data in XML format</body></html>\r\n";
		case 204:
			return "<html><title>test</title><body> 204 No Content</body></html>\r\n";
		case 400:
			return "<html><title>test</title><body>400bad request</body></html>\r\n";
		case 404:
			return "<html><title>test</title><body> 404 Not found</body></html>\r\n";
		case 500:
			return "<html><title>test</title><body> 500 Internal server error</body></html>\r\n";
		case 501:
			return "<html><title>test</title><body>501 Not Implemented</body></html>\r\n";
		case 505:
			return "<html><title>test</title><body>505 HTTP version not supported</body></html>\r\n";

		}
		return null;

	}
}
